<template>
  <div class="detail">
    <nav-top title="港医咨询详情" :goback="true"></nav-top>
    <section class="partOne">
      <div class="order">
        <span>订单编号：&nbsp;&nbsp;&nbsp;&nbsp;{{orderInfo.order_no}}</span>
      </div>
      <div class="status">
        <span>当前状态：&nbsp;&nbsp;&nbsp;&nbsp;{{ orderInfo.status == 1 ? "待支付" : orderInfo.status == 2 ? orderInfo.write_off ?  "已回答" : "待回复" : "已取消" }}</span>
      </div>
      <div class="price">
        <span>支付费用：&nbsp;&nbsp;&nbsp;&nbsp;{{ orderInfo.total_fee/100 == 0 ? orderInfo.desc: ""+orderInfo.total_fee/100}}</span>
      </div>
      <div class="gap"></div>
    </section>
    <section class="partTwo">
      <div class="img">
        <img :src="product.imgUrl" alt v-show="false"/>
      </div>
      <div class="msg">
        <p class="name">{{orderInfo.body}}</p>
        <p class="price">支付价格：￥{{orderInfo.total_fee/100}}</p>
        <p class="time">{{orderInfo.CreatedAt.substring(0,10)+' '+orderInfo.CreatedAt.substring(11,19) }}</p>
      </div>
    </section>
    <div class="gap"></div>
    <section class="partThree" v-show="true">
      <header>咨询信息</header>
      <div class="disable">
        <span class="input">咨询问题：{{form.title}}</span>
      </div>
      <div class="disable">
        <span class="input">问题描述：{{form.desc}}</span>
      </div>
      <div class="">
      <header>图片咨询</header>
      <van-image-preview
      v-model="imgListpreview"
      :images="imgList"
      @change="onChange"
    >
      <template v-slot:imgListindex>第{{ imgListindex }}页</template>
    </van-image-preview>
      <van-swipe class="img" v-if="showImg" :autoplay="3000" indicator-color="#06A44F">
        <van-swipe-item v-for="(val,key) in imgList" :key="key">
          <img :src="val" width="100%" height="250px" class="img" @click="showimgListpreview(key)"/>
        </van-swipe-item>
      </van-swipe>
      </div>

    </section>
    <div class="gap"></div>
    <section  class="partThree" v-show="true">
      <header>联系信息</header>
      <div class="disable">
        <span class="input">姓名：{{form.name}}</span>
      </div>
      <div class="disable">
        <span class="input">联系方式：{{form.contact}}</span>
      </div>
    </section>
    <hr style="visibility:hidden" />
  </div>
</template>

<script>
import NavTop from "@/components/nav/navBar";
import { domain, search } from '@/api'
import axios from 'axios'

export default {
  name: "AppointmentDetail",
  components: {
    NavTop
  },
  filters: {
    setStatus(val) {
      if (val == 1) return "已提交";
      if (val == 2) return "未提交";
    }
  },
  methods:{
    onChange(imgListindex) {
      this.imgListindex = imgListindex;
    },
    showimgListpreview(key){
      this.onChange(key)
      this.imgListpreview = true
    }
  },
  created:function(){
    // this.orderInfo = null
    // /api/order/info?order_no=bx3t1bhysprg2585378391
    axios.post(domain + "/api/order/info?order_no="+ search('order_no'))
    .then((res)=>{
      if(res.data.code==1){
        this.orderInfo = res.data.data
      }
    })
    .catch((err)=>{

    })
    axios.get(domain+"/api/consultdoctor/from/info?order_no="+ search('order_no'))
    .then((res)=>{
      if(res.data.code==1){
        this.form = res.data.data
        if(res.data.data.images != ""){
          this.showImg = true
          this.imgList = res.data.data.images.split(",")
        }
      }
    })
    .catch((err)=>{

    })
  },
  data() {
    return {
      imgListindex:0,
      imgListpreview:false,
      orderInfo:{
        CreatedAt: "2019-09-19T15:36:06+08:00",
        DeletedAt: null,
        ID: 268,
        UpdatedAt: "2019-09-19T15:36:15+08:00",
        body: "加载中",
        call_used: "加载中",
        call_used_url: "/user/member",
        call_using: "加载中",
        call_using_url: "/user/member",
        desc: "加载中",
        discount: "加载中",
        fee_type: "加载中",
        is_discount: false,
        is_reward_point: false,
        is_upgrade: false,
        order_no: "加载中",
        pay_type: "WeChat",
        product_id: 1,
        status: '加载中',
        total_fee: null,
        trade_state: "SUCCESS",
        user_id: '加载中',
        write_off: true,
      },
      orderNum: 190918170524436,
      status: 1,
      price: "7020",
      showImg:false,
      imgList:"",
      product: {
        imgUrl: "/static/img/product-img.png",
        name: "产品名称显示产品名称显示产品显示产品",
        time: "2019-09-19 17:11 星期四",
        price: "7020"
      },
      form: {
      }
    };
  }
};
</script>

<style lang="scss" scoped>
.gap {
  width: 320px;
  height: 9px;
  background: #f7f7f7;
}
.detail {
  overflow: hidden;
  overflow-y: auto;
  min-height: 690px;
  span,
  p {
    line-height: 1em;
  }
  .partOne {
    .order {
      width: 320px;
      margin: 53px 0 0 15px;
      span {
        font-size: 12px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(36, 36, 36, 1);
      }
    }
    .status,
    .price {
      margin: 18px 0 0 15px;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(36, 36, 36, 1);
    }
    .price{
      padding-bottom: 12px;
    }
  }
  .partTwo {
    display: flex;
    height: 109px;
    .img {
      margin: 13px 0 17px 13px;
      img {
        width: 76px;
        height: 76px;
      }
    }
    .msg {
      margin: 17px 0 0 14px;
      .name {
        margin: 0;
        font-size: 12px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(36, 36, 36, 1);
        width: 193px;
            overflow: hidden;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
            white-space: nowrap;
      }
      .price,.time {
        font-size: 11px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(102, 102, 102, 1);
      }
      .price {
        margin-top: 12px;
      }
      .time {
        display: block;
        margin-top: 26px;
      }
    }
  }
  .partThree {
    margin-bottom: 20px;
    header {
      height: 44px;
      font-size: 15px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: rgba(0, 0, 0, 1);
      line-height: 44px;
      padding-left: 14px;
      border: 2px solid #f7f7f7;
    }
    .disable,
    .address {
      height: 41px;
      background: #fff;
      border-bottom: 1px solid #ececec;
      .input, div {
        color: #242424;
        position: relative;
        padding: 0px;
        padding-left: 13px;
        padding-bottom: 11px;
        border-bottom: none;
        font-size: 13px;
        line-height: 41px;
        font-family: Microsoft YaHei;
        font-weight: 1em;
      }
    }
    .address {
      display: flex;
      height: 55px !important;
      background: #fff;
      border-bottom: none;
      .input, div {
        margin-top: 10px;
        line-height: 20px !important;
      }
      div{
        padding: 0;
        width: 209px;
      }
    }
  }
}
</style>